package com.wyq.action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.wyq.bean.ShowInfo;
import com.wyq.service.ShowInfoService;

public class GetShowInfoAction extends ActionSupport {
	private ShowInfoService showInfoService;
	private String flag;//为0时前台页面访问，保存session；为1时是后台页面访问，不保存session
	private List showInfoList;
	private String type;
	
	
	public void setShowInfoService(ShowInfoService showInfoService) {
		this.showInfoService = showInfoService;
	}
	
	public void setFlag(String flag) {
		this.flag = flag;
	}

	public List getShowInfoList() {
		return showInfoList;
	}

	public String search(){
		//List showInfoList;
		//System.out.println("*********" + flag);
		try {
			showInfoList = showInfoService.getShowInfoById("1");
			if(flag == "0"){
			//当前可用的展会信息有且只有一个
			Map showInfo = (Map) showInfoList.get(0);
			//将展会的信息保存在session中
			Map session = ActionContext.getContext().getSession();
			session.put("showInfo", showInfo);
			}
			//System.out.println("-------" + showInfoList);
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			return INPUT;
		}
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
